<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		*{text-align:center;}
	</style>
	

		
	</script>
</head>
<body>
	<h1>简易计算器</h1>

	<p >第一个数字:<input type="text" name="" id="num1"></p>
	<p >第二个数字:<input type="text" name="" id="num2"></p>
	
	<input type="button" name="" value='+' onclick='getResult("+")'>
	<input type="button" name="" value='-' onclick='getResult("-")'>
	<input type="button" name="" value='*' onclick='getResult("*")'>
	<input type="button" name="" value='/' onclick='getResult("/")'>
	
	<p>计算结果为：<span id="result">0</span></p>

</body>
<script type="text/javascript">
		
			function getResult(fuhao){
			var num1=Number(document.getElementById('num1').value);
			var num2=Number(document.getElementById('num2').value);
			
				switch(fuhao){
					      case '+':
				          result.innerText=num1+num2;
				          break;


				          case '-':
				          result.innerText=num1-num2;
				          break;

				          case '*':

				          result.innerText=num1*num2;
				          break;

				          case '/':
				          result.innerText=num1/num2;
				          break;
				          }
			}
</script>
</html>